package com.hmkj.core.po.amount;

import com.hmkj.common.baseMapper.GenericPo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;


/**
 * 提现表实体信息<br>
 *
 * @author eproo
 * @date   2017-11-13 06:11:07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "提现表")
@Table(name = "fm_cash")
public class Cash extends GenericPo<Integer> {

    public static final String TABLE_NAME = "fm_cash";

	
	/**用户ID**/
	@ApiModelProperty(value = "用户ID")
	private Integer userId;
	/**1,线上提现:T1;2,线下提现:T2**/
	@ApiModelProperty(value = "1,线上提现:T1;2,线下提现:T2")
	private Integer type;
	@Transient
	private String typeFormatter ;
	/**提现是否需要审核，1需要，2不需要**/
	@ApiModelProperty(value = "提现是否需要审核，1需要，2不需要")
	private Integer needAudit;
	/**银行名称**/
	@ApiModelProperty(value = "银行名称")
	private String bankName;
	/**银行编码**/
	@ApiModelProperty(value = "银行编码")
	private String bankCode;
	/**银行卡号**/
	@ApiModelProperty(value = "银行卡号")
	private String bankNo;
	/**支行名称**/
	@ApiModelProperty(value = "支行名称")
	private String branch;
	/**提现金额**/
	@ApiModelProperty(value = "提现金额")
	private BigDecimal amount;
	/**持卡人姓名**/
	@ApiModelProperty(value = "持卡人姓名")
	private String realName;
	/**持卡人身份证**/
	@ApiModelProperty(value = "持卡人身份证")
	private String idCard;
	/**实际到账金额（手续费自承情况）**/
	@ApiModelProperty(value = "实际到账金额（手续费自承情况）")
	private BigDecimal actualArrival;
	/**用户承担手续费金额**/
	@ApiModelProperty(value = "用户承担手续费金额")
	private BigDecimal fee;
	/**平台承担手续费金额**/
	@ApiModelProperty(value = "平台承担手续费金额")
	private BigDecimal feePlat;
	/**订单号**/
	@ApiModelProperty(value = "订单号")
	private String orderNo;
	/**外部单号**/
	@ApiModelProperty(value = "外部单号")
	private String outOrderNo;
	/**1待处理，2处理中，3提现成功，4提现失败，5取消**/
	@ApiModelProperty(value = "1待处理，2处理中，3提现成功，4提现失败，5取消")
	private Integer status;
    @Transient
    private String statusFormatter ;
	/**第三方返回状态**/
	@ApiModelProperty(value = "第三方返回状态")
	private String outStatus;
	/**第三方返回消息**/
	@ApiModelProperty(value = "第三方返回消息")
	private Object outMsg;
	/**备注**/
	@ApiModelProperty(value = "备注")
	private String remark;
    public String getTypeFormatter() {
        if(null == typeFormatter || "".equals(typeFormatter)){
            return TYPE.getValue(getType());
        }
        return this.typeFormatter;
    }
    public void setTypeFormatter(String typeFormatter) {
        this.typeFormatter=typeFormatter;
    }
    public String getStatusFormatter() {
        if(null == statusFormatter || "".equals(statusFormatter)){
            return STATUS.getValue(getStatus());
        }
        return this.statusFormatter;
    }
    public void setStatusFormatter(String statusFormatter) {
        this.statusFormatter=statusFormatter;
    }
    /**1,线上提现:online<br>2,线下支付宝:alipay<br>3,线下微信:wechat<br>4,现下转账:bank**/
    public enum TYPE {

        /**1,线上提现:online**/
        ONLINE("线上提现",1),

        /**2,线下支付宝:alipay**/
        ALIPAY("线下支付宝",2),

        /**3,线下微信:wechat**/
        WECHAT("线下微信",3),

        /**4,现下转账:bank**/
        BANK("现下转账",4),

        /**3,用户取款:wechat**/
        DRAWMONEY("用户取款",5),

        /**6,结算修改:wechat**/
        SETTLEMENT("结算修改",6),

        /**7,垫付取回:wechat**/
        ADVANCE("垫付取回",7),

        /**8,备用金取回:wechat**/
        SPARE("备用金取回",8);

        public final int code;
        public final String value;
        private static Map<Integer, String> map = new HashMap<Integer, String>();

        private TYPE(String value, int code) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(Integer code) {
            if (null == code) {
                return null;
            }
            for (TYPE type : TYPE.values()) {
                if (type.code == code) {
                    return type.value;
                }
            }
            return null;
        }

        public static Integer getCode(String value) {
            if (null == value  || "".equals(value)) {
                return null;
            }
            for (TYPE type : TYPE.values()) {
                if (type.value.equals(value)) {
                    return type.code;
                }
            }
            return null;
        }

        public static  Map<Integer, String> getEnumMap() {
            if(map.size() == 0){
                for (TYPE type : TYPE.values()) {
                    map.put(type.code,type.value);
                }
            }
            return map;
        }
    }

    /**1待处理，2待审核，3待出账，4提现成功，5提现失败 6提现取消**/
    public enum STATUS {

        /**1,待处理:T1**/
        T1("待处理",1),// 发起提现申请后状态

        /**2,待审核:T2**/
        T2("待审核",2),// 调用双乾提现接口成功，等待调用审核接口的状态

        /**3,待出账:T3**/
        T3("待出账",3),// 调用审核接口审核通过，等待双乾回调审核结果状态

        /**4,提现成功:T4**/
        T4("提现成功",4),// 提现出账成功状态

        /**5,提现失败:T5**/
        T5("提现失败",5),// 提现出账失败状态

        /**6,提现取消:T6**/
        T6("提现取消",6);// 发起提现但未提交第三方，超时过期状态

        public final int code;
        public final String value;
        private static Map<Integer, String> map = new HashMap<Integer, String>();

        private STATUS(String value, int code) {
            this.code = code;
            this.value = value;
        }

        public static STATUS getEnum(Integer code){
            if (null == code) {
                return null;
            }
            for (STATUS status : STATUS.values()) {
                if (status.code == code) {
                    return status;
                }
            }
            return null;
        }
        public static String getValue(Integer code) {
            if (null == code) {
                return null;
            }
            for (STATUS status : STATUS.values()) {
                if (status.code == code) {
                    return status.value;
                }
            }
            return null;
        }

        public static Integer getCode(String value) {
            if (null == value  || "".equals(value)) {
                return null;
            }
            for (STATUS status : STATUS.values()) {
                if (status.value.equals(value)) {
                    return status.code;
                }
            }
            return null;
        }

        public static  Map<Integer, String> getEnumMap() {
            if(map.size() == 0){
                for (STATUS status : STATUS.values()) {
                    map.put(status.code,status.value);
                }
            }
            return map;
        }
    }

    /**提现是否需要审核，1需要，2不需要**/
    public enum NEEDAUDIT {

        /**1,需要:T1**/
        T1("需要",1),

        /**2,不需要:T2**/
        T2("不需要",2);

        public final int code;
        public final String value;
        private static Map<Integer, String> map = new HashMap<Integer, String>();

        private NEEDAUDIT(String value, int code) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(Integer code) {
            if (null == code) {
                return null;
            }
            for (NEEDAUDIT status : NEEDAUDIT.values()) {
                if (status.code == code) {
                    return status.value;
                }
            }
            return null;
        }

        public static Integer getCode(String value) {
            if (null == value  || "".equals(value)) {
                return null;
            }
            for (NEEDAUDIT status : NEEDAUDIT.values()) {
                if (status.value.equals(value)) {
                    return status.code;
                }
            }
            return null;
        }

        public static  Map<Integer, String> getEnumMap() {
            if(map.size() == 0){
                for (NEEDAUDIT status : NEEDAUDIT.values()) {
                    map.put(status.code,status.value);
                }
            }
            return map;
        }
    }


    public Cash(){}

    public Cash(Consumer<Cash> consumer){
        consumer.accept(this);
    }
}

